#define _CRT_SECURE_NO_WARNINGS 1
#include"list.h"
#include<list>
namespace List
{
	void test1()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);

		list<int>::iterator it = lt.begin();
		while (it != lt.end())
		{
			//*it += 10;

			cout << *it << " ";
			++it;
		}
		cout << endl;

		lt.pop_back();
		for (auto& e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.push_front(10);
		lt.push_front(20);
		lt.push_front(30);
		lt.push_front(40);

		for (auto& e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.pop_front();
		lt.pop_front();

		for (auto& e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		cout << lt.back() << " " << lt.front() << endl;
	}

	void test2()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);


		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.push_back(5);
		lt.push_front(0);

		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.pop_back();
		lt.pop_front();

		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.clear();

		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.push_back(10);
		lt.push_back(20);

		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	void test3()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);
		lt.push_back(5);
		lt.push_back(6);
		lt.push_back(7); 
		cout << lt.size() << endl;
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> copy(lt);
		for (auto e : copy)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> lt1;
		lt1.push_back(10);
		lt1.push_back(20);
		lt1.push_back(30);
		lt1.push_back(40);
		for (const auto e : lt1)
		{
			cout << e << " ";
		}
		cout << endl;

		lt = lt1;
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	void print_list(const list<int>& lt)
	{
		list<int>::const_iterator it = lt.begin();
		while (it != lt.end())
		{
			//*it += 10;

			cout << *it << " ";
			++it;
		}
		cout << endl;

		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	struct AA
	{
		int _a1;
		int _a2;

		AA(int a1 = 1, int a2 = 1)
			:_a1(a1)
			, _a2(a2)
		{}
	};

	void test4()
	{
		list<AA> lt;
		AA aa1;
		lt.push_back(aa1);

		lt.push_back(AA());

		AA aa2(2, 2);
		lt.push_back(aa2);

		lt.push_back(AA(2, 2));

		list<AA>::iterator it = lt.begin();
		while (it != lt.end())
		{
			cout << (*it)._a1 << ":" << (*it)._a2 << endl;
			cout << it.operator*()._a1 << ":" << it.operator*()._a2 << endl;

			cout << it->_a1 << ":" << it->_a2 << endl;
			cout << it.operator->()->_a1 << ":" << it.operator->()->_a2 << endl;

			++it;
		}
		cout << endl;
	}

	void test5()
	{
		list<int> li;
		li.push_back(1);
		li.push_back(2);
		li.push_back(3);
		li.push_back(4);

		//while (it1 != li.cend())
		//{
		//	//(*it1)++;
		//	(*it2)++;
		//	cout << *it1 << " ";
		//	it1++;
		//	it2++;
		//}

		
		list<int>::const_iterator it1 = li.cbegin();
		//list<int>::iterator it2 = li.cbegin();
		list<int>::iterator it2 = li.begin();
		list<int>::const_reverse_iterator crit = li.crbegin();


	}
}
void test5()
{
	list<int> li;
	li.push_back(1);
	li.push_back(2);
	li.push_back(3);
	li.push_back(4);

	list<int>::const_iterator it1 = li.begin();
	//list<int>::iterator it2 = li.cbegin();
	list<int>::iterator it2 = li.begin();
	list<int>::const_reverse_iterator crit = li.rbegin();

	while (it1 != li.end())
	{
		//(*it1)++;
		(*it2)++;
		cout << *it1 << " ";
		it1++;
		it2++;
	}

}
int main()
{
	//List::test1();
	//List::test2();
	//List::test3();
	/*List::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	List::print_list(lt);*/
	//List::test4();
	List::test5();

	return 0;
}
